package com.ruoyi.business.order.domain;

import cn.hutool.core.util.ObjectUtil;
import com.alibaba.fastjson.JSONArray;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.ruoyi.business.base.JoBaseEntity;
import com.ruoyi.common.annotation.Excel;
import lombok.Data;

import javax.validation.constraints.NotEmpty;
import java.math.BigDecimal;
import java.util.Date;

/**
 * 订单对象 jb_order
 *
 * @author ruoyi
 * @date 2024-10-11
 */
@Data
public class JbOrder extends JoBaseEntity
{
    private static final long serialVersionUID = 1L;

    /**
     * 订单编号
     */
    @Excel(name = "订单编号")
    private String orderNumber;

    /**
     * 流程编号
     */
    @Excel(name = "流程编号")
    private String processNumber;

    /**
     * 订单来源（字典：淘宝，京东，录入）
     */
    @Excel(name = "订单来源", readConverterExp = "字=典：淘宝，京东，录入")
    private String orderSource;

    /**
     * 客户id
     */
    @Excel(name = "客户id")
    private Long customerId;

    /**
     * 客户姓名
     */
    @Excel(name = "客户姓名")
    private String customerName;

    /**
     * 业务经理id
     */
    @Excel(name = "业务经理id")
    private Long businessManagerId;

    /**
     * 业务经理
     */
    @Excel(name = "业务经理")
    private String businessManager;

    /**
     * 金额核算类型
     */
    @Excel(name = "金额核算类型")
    private String priceType;

    /**
     * 付款类型 全款/定金
     */
    @Excel(name = "付款类型")
    @NotEmpty(message = "付款类型 不能为空")
    private String paymentType;

    /**
     * 付款方式
     */
    @Excel(name = "付款方式")
    private String paymentMethod;

    /**
     * 订单状态
     */
    @Excel(name = "订单状态")
    private String orderStatus;

    /**
     * 备注
     */
    @Excel(name = "备注")
    private String remark;
    /**
     * 发货备注
     */
    private String deliverGoodsRemark;

    /**
     * 付款截图url
     */
    @Excel(name = "付款截图url")
    private String paymentUrl;

    /**
     * 收货人
     */
    @Excel(name = "收货人")
    private String recipient;

    /**
     * 收货人手机号
     */
    @Excel(name = "收货人手机号")
    private String recipientPhone;

    /**
     * 收货地址
     */
    @Excel(name = "收货地址")
    private String shippingAddress;

    /**
     * 物流id
     */
    @Excel(name = "物流id")
    private Long logisticsId;

    /**
     * 物流名称
     */
    @Excel(name = "物流名称")
    private String logistics;

    /**
     * 文档单据类型
     */
    @Excel(name = "文档单据类型")
    private String documentType;

    /**
     * 物流单号
     */
    @Excel(name = "物流单号")
    private String logisticsNumber;

    /**
     * 地区编码
     */
    private String areaCode;
    private String areaCodeAll;

    /**
     * 运费
     */
    @Excel(name = "运费")
    private BigDecimal shippingFee;

    /**
     * 客户类型
     */
    @Excel(name = "客户类型")
    private String customerType;

    /**
     * 客户渠道(线上线下)
     */
    @Excel(name = "客户渠道(线上线下)")
    private String opportunityChannel;

    /**
     * 是否有赠品
     */
    @Excel(name = "是否有赠品")
    private String hasGift;

    /**
     * 数量
     */
    @Excel(name = "数量")
    private BigDecimal quantity;

    /**
     * 订单总金额
     */
    @Excel(name = "订单总金额")
    private BigDecimal orderTotalAmount;

    /**
     * 订单实付金额
     */
    @Excel(name = "订单实付金额")
    private BigDecimal realOrderAmount;

    /**
     * 订单 实际金额
     */
    @Excel(name = "订单申报金额")
    private BigDecimal declareAmount;

    /**
     * 订单差额
     */
    @Excel(name = "订单差额")
    private BigDecimal differenceAmount;

    /**
     * 订单定金金额
     */
    @Excel(name = "订单定金金额")
    private BigDecimal depositAmount;

    /**
     * 订单毛利率
     */
    @Excel(name = "订单毛利率")
    private BigDecimal orderGrossProfitRate;

    /**
     * 回款金额
     */
    @Excel(name = "回款金额")
    private BigDecimal receivedAmount;

    /**
     * 归属部门
     */
    @Excel(name = "归属部门")
    private String belongDepartment;

    /**
     * 归属战区
     */
    @Excel(name = "归属战区")
    private String belongSalesZone;

    /**
     * 申请时间
     */
    @JsonFormat(pattern = "yyyy-MM-dd")
    @Excel(name = "申请时间", width = 30, dateFormat = "yyyy-MM-dd")
    private Date applyTime;

    /**
     * 业务经理审核时间
     */
    @JsonFormat(pattern = "yyyy-MM-dd")
    @Excel(name = "业务经理审核时间", width = 30, dateFormat = "yyyy-MM-dd")
    private Date managerAuditTime;

    /**
     * 业务经理审核结果
     */
    @Excel(name = "业务经理审核结果")
    private String managerAuditResult;

    /**
     * 主管审核时间
     */
    @JsonFormat(pattern = "yyyy-MM-dd")
    @Excel(name = "主管审核时间", width = 30, dateFormat = "yyyy-MM-dd")
    private Date supervisorAuditTime;

    /**
     * 主管审核结果
     */
    @Excel(name = "主管审核结果")
    private String supervisorAuditResult;

    /**
     * 财务审核时间
     */
    @JsonFormat(pattern = "yyyy-MM-dd")
    @Excel(name = "财务审核时间", width = 30, dateFormat = "yyyy-MM-dd")
    private Date financeAuditTime;

    /**
     * 财务审核结果
     */
    @Excel(name = "财务审核结果")
    private String financeAuditResult;

    /**
     * 订单提成方式
     */
    @Excel(name = "订单提成方式")
    private String commissionMethod;

    /**
     * 订单提成金额
     */
    @Excel(name = "订单提成金额")
    private BigDecimal commissionAmount;

    /**
     * 结束订单备注
     */
    @Excel(name = "结束订单备注")
    private String closeRemark;

    /**
     * 置顶时间
     */
    private Date topTime;

    /**
     * 是否有赠品
     */
    private Boolean isHaveGift;

    /**
     * 是否流程已走完
     */
    private Boolean isProcessEnd;

    /**
     * 是否业务已走完
     */
    private Boolean isBusinessEnd;

    /**
     * 用友 销货单
     */
    private String yySaleDeliveryCode;

    /**
     * 用友 订单查询 次数
     */
    private int yySalesOrderCount;

    /**
     * 用友 订单查询 是否已全部记录
     */
    private boolean yySaleDeliveryIsAll;

    /**
     * 用友 售订单
     */
    private String yySaleOrderCode;

    /**
     * 用友 物流信息
     */
    @TableField(typeHandler = JacksonTypeHandler.class)
    private JSONArray yyLogisticsInformation;

    /**
     * 用友 物流信息 是否已全部记录
     */
    private boolean yyLogisticsIsAll;

    /**
     * 省市区 名称
     */
    private String localProvinceName;
    private String localCityName;
    private String localCountyName;
    private String shippingAddressShort;

    /**
     * 赋值
     *
     * @param object
     */
    public void setYyLogisticsInformation(Object object)
    {
        if (ObjectUtil.isNotEmpty(object))
        {
            this.yyLogisticsInformation = JSONArray.parseArray(object.toString());
        }
    }

}
